package sync.main;

import static org.quartz.JobBuilder.newJob;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
import static org.quartz.TriggerBuilder.newTrigger;
import static org.quartz.CronScheduleBuilder.cronSchedule;

import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.Trigger;
import org.quartz.impl.StdSchedulerFactory;

import sync.quartz.PKTenJob;
import sync.quartz.SSCJob;
import sync.quartz.SSCPlanFiveJob;

public class SyncStart {

	public void start(){
		
		try {
			// sync ssc data
			SchedulerFactory sf = new StdSchedulerFactory();
			Scheduler sched = sf.getScheduler();
		
			JobDetail jobsscd = newJob(SSCJob.class).withIdentity("job1", "group1").build();
			
		    Trigger triggersscd = newTrigger().withIdentity("trigger1", "group1").startNow().withSchedule(
		    		cronSchedule("3,15,20,30,35,38,51,59 "//秒
		    				+ "1,2,6,7,11,12,16,17,21,22,26,27,31,32,36,37,41,42,46,47,51,52,56,57 * * * ? *")).build();//分

		    sched.scheduleJob(jobsscd,triggersscd);
		    
		    JobDetail jobsscfive = newJob(SSCPlanFiveJob.class).withIdentity("job2", "group1").build();
			
		    Trigger triggersscdfive = newTrigger().withIdentity("trigger2", "group1").startNow().withSchedule(
		    		cronSchedule("3,15,20,30,35,38,51,59 "//秒
		    				+ "1,2,6,7,11,12,16,17,21,22,26,27,31,32,36,37,41,42,46,47,51,52,56,57 * * * ? *")).build();//分
		    sched.scheduleJob(jobsscfive,triggersscdfive);
		    
		    JobDetail jobpk = newJob(PKTenJob.class).withIdentity("job3", "group1").build();
		    
		    Trigger triggerpk = newTrigger().withIdentity("trigger3", "group1").startNow().withSchedule(
		    		cronSchedule("3,15,20,30,35,38,51,59 "//秒
		    				+ "2,3,7,8,12,13,17,18,22,23,27,28,32,33,37,38,42,43,47,48,52,53,57,58 * * * ? *")).build();//分
		    sched.scheduleJob(jobpk,triggerpk);
		    
		    
		    sched.start();
		} catch (SchedulerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	
}
